<template>
  <div>
    <div class="banner">
      <h1 class="banner-title">归档</h1>
    </div>
    <el-card class="cardbg">
      <el-row :gutter="0">
        <el-col :span="14" :offset="2">
          <el-timeline
            v-for="(timeline, index) in timelineData"
            :key="index"
            
          >
            <h2 class="year">{{ timeline.year }}</h2>
            <el-timeline-item
              v-for="(item, index) in timeline.items"
              :key="index"
              :timestamp="item.gmtCreate"
              placement="top"
            >
              <el-card>
                <h1>
                  <router-link class="title" :to="'/post/' + item.id">{{
                    item.title
                  }}</router-link>
                </h1>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import request from "@/http/request";

export default {
  name: "TimeLine",
  data() {
    return {
      timelineData: [],
    };
  },
  created() {
    request
      .getTimeline()
      .then((res) => {
        if (res.code === 0) {
          this.timelineData = res.data;
        } else {
          this.$notify.error({
            title: "提示",
            message: res.msg,
          });
        }
      })
      .catch((err) => {
        console.log(err);
        this.$notify.error({
          title: "提示",
          message: "网络繁忙，标签时间线获取失败。",
        });
      });
  },
};
</script>

<style scoped>
.banner {
  /* position: absolute; */
  background-color: #49b1f5 !important;
  top: -60px;
  left: 0;
  right: 0;
  height: 320px;
  animation: header-effect 1s;
  opacity: 0.8;
  background: url("http://img.xiyblog.cn/%E5%AF%BC%E8%88%AA/other/ot1%20%283%29.jpg")
    center center / cover no-repeat;
}
.banner-title {
  animation: title-scale 1s;
  position: absolute;
  top: 11.5rem;
  padding: 0 0.5rem;
  width: 100%;
  font-size: 2.5rem;
  text-align: center;
  color: #eee;
}
.cardbg {
  /* background-color: #eee; */
  opacity: 0.8;
  /* height: 80px; */
  /* display: flex;
  flex-direction: column; */
  position: relative;
  animation: main 1s;
  max-width: 951px;
  padding: 50px 40px;
  margin: 26px auto 17px auto;
}
.el-row {
  margin-top: 20px;
}
.year {
  margin-bottom: 10px;
}
.title {
  font-size: 24px;
  text-decoration: none;
  color: #606266;
  padding-left: 24px;
}
.title:hover {
  cursor: pointer;
  color: #0a0a0a;
}
</style>
